package com.example.woke;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.woke.fragment.PuFaIdCardAuthFragment;
import com.zhongcai.online.R;

/**
 * Created by Administrator on 2017/4/15 0015.
 */

public class SwithFragmentActivity extends AppCompatActivity {


    private static final String KEY_FRAGMENT = "switch_fragment";

    private static final int PUFA_IDCARD_AUTH = 89;//浦发 身份证照认证

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_switch_fragment);
        Intent intent = getIntent();
        if (intent != null) {
            Bundle bundle = intent.getExtras();
            if (bundle != null) {
                switchFragment(bundle.getInt(KEY_FRAGMENT, -1), bundle);
            }
        }

    }

    public static void newPufaIcCardAuthFragment(Context context) {
        Intent intent = new Intent(context, SwithFragmentActivity.class);
        Bundle bundle = new Bundle();
        bundle.putInt(KEY_FRAGMENT, PUFA_IDCARD_AUTH);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    private void switchFragment(int tag, Bundle bundle) {
        Fragment fragment = null;
        Log.e("swithfragment", "--" + tag);
        switch (tag) {
            case PUFA_IDCARD_AUTH:
                fragment = new PuFaIdCardAuthFragment();
                break;


        }
        if (fragment != null) {
            getSupportFragmentManager().beginTransaction().replace(R.id.switchContainer, fragment).commit();
        }

    }
}
